package com.sphd.emanu.activity.moneymessage;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.sphd.emanu.R;
import com.sphd.emanu.config.Constant;
import com.sphd.emanu.fragment.day.DayFragment;
import com.sphd.emanu.fragment.month.MonthFragment;
import com.sphd.emanu.fragment.search.SearchFragment;
import com.sphd.emanu.interfaces.LetterAtoF;
import com.sphd.emanu.mvp.MVPBaseActivity;
import com.sphd.emanu.utils.GetTimeTask;
import com.wzutils.TimeUtils;

import java.text.ParseException;
import java.util.Calendar;

import javax.inject.Inject;

/**
 * 财务详情
 *
 * @Author Hu
 * @Time 2017/7/10 -- 10:35.
 * @Email 87683202@qq.com
 */
// TODO: 2017/7/10 该界面因共用 故分为多个fragemt按照分类进行区分
public class MoneyMessageActivity extends MVPBaseActivity<MoneyMessageContract.View, MoneyMessagePresenter> implements MoneyMessageContract.View, LetterAtoF {

    MonthFragment monthFragment;//本月上月本年信息显示
    DayFragment dayFragment;//昨天今天本月上月支出收入分开显示
    SearchFragment searchFragment;//按搜索的时间和类别收入支出余额显示不同信息
    Intent intent;
    Bundle bundle;
    private int flagForCardView = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_money_message);
        initView();

    }




    private void initView() {
        intent = getIntent();
        bundle = intent.getExtras();
        flagForCardView = bundle.getInt(Constant.R_ID);//用来判断是那个按钮传进来的然后显示不同信息
        monthFragment = new MonthFragment();
        monthFragment.setLetterAtoF(this);
        dayFragment = new DayFragment();
        dayFragment.setLetterAtoF(this);
        searchFragment = new SearchFragment();
        searchFragment.setLetterAtoF(this);
        dayFragment.setArguments(bundle);
        searchFragment.setArguments(bundle);
        //分别把信息在传入到下个fragment
        //因时获取时间目前改为暂不获取 待到需要时开启
        getFlagCard(flagForCardView);//fragment显示


    }

    private void getFlagCard(int flagForCardView) {
        switch (flagForCardView) {
            case R.id.balance_now_image:
                monthFragment.setArguments(bundle);
                changeFragment(R.id.activity_money_message, monthFragment, Constant.NowMothMessage);
                break;
            case R.id.balance_lastmonth_image://上月信息
                monthFragment.setArguments(bundle);
                changeFragment(R.id.activity_money_message, monthFragment, Constant.LastMonthMessge);
                break;
            case R.id.today_income_image://今日收入
                changeFragment(R.id.activity_money_message, dayFragment, Constant.TodayI);
                break;
            case R.id.today_spending_image://今日支出
                changeFragment(R.id.activity_money_message, dayFragment, Constant.TodayO);
                break;
            case R.id.search_image:
                //搜索进来的界面
                changeFragment(R.id.activity_money_message, searchFragment, Constant.SearchFragment);
                break;
//            case R.id.show_time_cardview://搜索后单条列表进入
//                changeFragment(R.id.activity_money_message, searchFragment, Constant.SearchFragment);
//                break;
        }
    }



    @Override
    public void finishActivity() {
        finish();
    }
}
